package com;


import com.spi.SpiService;
import sun.misc.Service;

import java.util.Iterator;
import java.util.ServiceLoader;

public class ServiceApp {

    public static void main(String[] args) {
        Iterator<SpiService> providers = Service.providers(SpiService.class);
        while(providers.hasNext()){
            SpiService next = providers.next();
            System.out.println(next.getClass().getName());
            System.out.println(next.showMessage());
        }

        ServiceLoader<SpiService> loader = ServiceLoader.load(SpiService.class);
        for (SpiService next : loader) {
            System.out.println(next.getClass().getName());
            System.out.println(next.showMessage());
        }
    }

}
